<?php

namespace App\Http\Controllers\user;

use App\Dao\BalanceZhuBillsDao;
use App\Dao\BankDao;
use App\Dao\BillsDao;
use App\Dao\CommonDao;
use App\Dao\ConsumerCouponBillsDao;
use App\Dao\OliBillsDao;
use App\Dao\OlisDao;
use App\Dao\UsersDao;
use App\Exceptions\SysExceptions;
use App\Services\Code;
use App\Services\WechatServices;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
use EasyWeChat\Kernel\Exceptions\RuntimeException;
use League\CommonMark\Block\Element\ListData;

class CommonController extends BaseController
{
    public function olis(): array
    {
        return Code::message('',200,OlisDao::olis([
            'status'=>0
        ]));
    }


    public function bills(): array
    {
        $params = array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        return Code::message('',200,BillsDao::bills($params));
    }

    public function oli_bills(): array
    {
        $params = array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        return Code::message('',200,OliBillsDao::oliBills($params));
    }

    public function consumer_coupon_bills(): array
    {
        $params = array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        return Code::message('',200,ConsumerCouponBillsDao::consumerCouponBills($params));
    }


    /**
     * @throws InvalidArgumentException
     * @throws SysExceptions
     * @throws RuntimeException
     */
    public function qr_code(): array
    {
        $params = request()->all();
        return Code::message('',200,WechatServices::qr_code($params));
    }

    public function user_send_balance(): array
    {
        $params = array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        UsersDao::user_send_balance($params);
        return Code::message('',200);
    }


    public function data_s(): array
    {
        return Code::message('',200,CommonDao::data_s([
            'user_id'=>getUserToken()
        ]));
    }


    public function bill_count(): array
    {
        $params = array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        return Code::message('',200,BillsDao::bills_count($params));
    }

    public function banks(): array
    {
        return Code::message('',200,BankDao::banks([
            'status'=>0
        ]));
    }


    public function bills_lists(): array
    {
        return Code::message('',200,BalanceZhuBillsDao::bills_lists(array_merge([
            'user_id'=>getUserToken()
        ],request()->all())));
    }

    /**
     * @return array
     */
    public function get_hexiao_code(): array
    {
        return Code::message('',200,CommonDao::get_hexiao_code(array_merge([
            'user_id'=>getUserToken()
        ],request()->all())));
    }


    public function he_xiao()
    {
        $params = array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        CommonDao::hexiao($params);
        return Code::message('',200);
    }
}
